package com.ssd.controller.operation;


import com.ssd.entity.Gift;
import com.ssd.entity.dto.request.GiftQueryForPageReqDTO;
import com.ssd.entity.dto.request.GiftSaveReqDTO;
import com.ssd.entity.dto.request.GiftUpdateReqDTO;
import com.ssd.entity.dto.response.GiftPageInfoResDTO;
import com.ssd.service.IGiftService;
import com.ssd.viewmodel.Pager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.Null;

/**
 * <p>
 * 运营端-礼品表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-11-21
 */
@RestController("operationGiftController")
@RequestMapping("/operation/gift")
@Api(tags = "运营端-礼品表控制器")
@Validated
public class GiftController {
    @Resource
    private IGiftService giftService;

    /**
     * 保存礼品信息
     * @param giftSaveReqDTO 保存礼品请求模型
     */
    @PostMapping("/save")
    @ApiOperation(value = "保存礼品信息")
    public void save(@ApiParam(value = "保存礼品请求模型") @RequestBody GiftSaveReqDTO giftSaveReqDTO){
        giftService.save(giftSaveReqDTO);
    }

    /**
     * 根据礼品id查看礼品详情
     * @param id 礼品id
     * @return
     */
    @GetMapping("/{id}")
    @ApiOperation(value = "根据礼品id查看礼品详情")
    public Gift getDetail(@PathVariable("id")  Long id){
        return giftService.getById(id);
    }

    /**
     * 删除礼品信息
     * @param id 礼品id
     */
    @DeleteMapping ("/revoke/{id}")
    @ApiOperation(value = "根据礼品id删除礼品信息")
    public void  revoke(@PathVariable("id") Long id){
        giftService.removeById(id);
    }

    /**
     * 修改礼品信息
     * @param giftUpdateReqDTO 修改礼品请求模型
     */
    @PutMapping("/update")
    @ApiOperation(value = "根据礼品id修改信息")
    public void update(@ApiParam(value = "修改礼品请求模型") @RequestBody GiftUpdateReqDTO giftUpdateReqDTO){
        giftService.update(giftUpdateReqDTO);
    }

    /**
     * 分页查询礼品信息
     * @return
     */
    @GetMapping("/page")
    @ApiOperation(value = "分页查询礼品信息")
    public Pager<GiftPageInfoResDTO> queryGiftForPage(GiftQueryForPageReqDTO giftQueryForPageReqDTO){
        return giftService.queryGiftForPage(giftQueryForPageReqDTO);
    }


}
